package com.lagou.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.lagou.mappr.TokenMapper;
import com.lagou.pojo.Token;
import com.lagou.service.LocalUserService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.ObjectUtils;

/**
 * @ClassName LocalUserServiceImpl
 * @Description
 * @Author playboy
 * @Date 2021/7/10 11:00 下午
 * @Version 1.0
 **/
@Service
@Transactional
public class LocalUserServiceImpl implements LocalUserService {
	private static Logger log = LoggerFactory.getLogger(LocalUserServiceImpl.class);

	@Autowired
	private TokenMapper tokenMapper;

	/**
	 * 查询信息
	 *
	 * @param token
	 * @return
	 */
	@Override
	public String info(String token) {
		QueryWrapper<Token> queryWrapper = new QueryWrapper<>();
		queryWrapper.eq("token", token);
		Token token1 = tokenMapper.selectOne(queryWrapper);
		if (ObjectUtils.isEmpty(token1)) {
			return null;
		}
		return token1.getEmail();
	}
}
